package nuc.edu.tlias.mapper;

import nuc.edu.tlias.pojo.Clazz;
import nuc.edu.tlias.pojo.ClazzCountOption;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ClazzMapper {

    @Insert("     INSERT INTO clazz (name, room, begin_date, end_date, master_id, subject, create_time, update_time) values (#{name}, #{room}, #{beginDate}, #{endDate}, #{masterId}, #{subject}, #{createTime}, #{updateTime})")
    void add(Clazz clazz);

    @Select("SELECT id, name, room, begin_date, end_date, master_id, subject, create_time, update_time from clazz")
    List<Clazz> findAll();

    List<Clazz> searchPage(@Param("name") String name,@Param("begin") LocalDate begin,@Param("end") LocalDate end);

    @Delete("DELETE from clazz where id = #{id}")
    void deleteById(Integer id);

    @Select("select id, name, room, begin_date, end_date, master_id, subject, create_time, update_time from clazz where id = #{id}")
    Clazz findById(Integer id);

    void upload(Clazz clazz);
}
